package com.xjl.example.aqs;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * Created by xiaojinlu1990@163.com on 2019/11/30.
 * FutureTask  如果中间想做一些事情的话又不想影响现在的性能可以引入
 * futuretask   性能是个好东西
 *
 */
@Slf4j
public class FutureTaskExample {



    public static void main(String[] args) throws InterruptedException, ExecutionException {
        FutureTask<String> future = new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                Thread.sleep(1000);
                log.info("do Something start");
                return "Down";
            }
        });

        new Thread(future).start();
        Thread.sleep(1000);
        log.info("do something mian");
        String result = future.get();
        log.info("return{}",result);
    }




}
